package icu.sehnen.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import icu.sehnen.user.entity.RolePermissionRelation;
import icu.sehnen.user.mapper.RolePermissionRelationMapper;
import icu.sehnen.user.service.IRolePermissionRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.beans.Transient;

/**
 * <p>
 * 后台用户角色和权限关系表 服务实现类
 * </p>
 *
 * @author icu.sehnen
 * @since 2021-04-27
 */
@Service
public class RolePermissionRelationServiceImpl extends ServiceImpl<RolePermissionRelationMapper, RolePermissionRelation> implements IRolePermissionRelationService {
@Autowired
RolePermissionRelationMapper rolePermissionRelationMapper;
    @Override
    public Integer deletePermissionById(Long roleId, Long rightId) {
        return  1;
    }

    @Override
    @Transient
    public void addRight(Long [] ids, Long id) {
        UpdateWrapper updateWrapper=new UpdateWrapper();
        updateWrapper.eq("role_id",id);
        rolePermissionRelationMapper.delete(updateWrapper);
            rolePermissionRelationMapper.instert(ids,id);

    }
}
